<!doctype html>
<html lang="zh-CN">
<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
    <meta name="referrer" content="no-referrer-when-downgrade">
    

    <title>安装jupyter Notebook环境 | Mr.代的个人博客</title>
    <meta property="og:title" content="安装jupyter Notebook环境 - Mr.代的个人博客">
    <meta property="og:type" content="article">
        
    <meta property="article:published_time" content='2020-12-09T13:42:34&#43;08:00'>
        
        
    <meta property="article:modified_time" content='2020-12-09T13:42:34&#43;08:00'>
        
    <meta name="Keywords" content="golang,go语言,go语言笔记,飞雪无情,java,android,博客,项目管理,python,软件架构,公众号,小程序">
    <meta name="description" content="安装jupyter Notebook环境">
        
    <meta name="author" content="靈靈">
    <meta property="og:url" content="https://www.daleyblog.cn/post/%E5%AE%89%E8%A3%85jupyter-notebook%E7%8E%AF%E5%A2%83/">
    <link rel="shortcut icon" href='/favicon.ico'  type="image/x-icon">

    <link rel="stylesheet" href='/css/normalize.css'>
    <link rel="stylesheet" href='/css/style.css'>
    <script type="text/javascript" src="//cdn.bootcdn.net/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

    
    
    
    
    
    
        <link rel="stylesheet" href='/css/douban.css'>
    
        <link rel="stylesheet" href='/css/other.css'>
    
</head>


<body>
    <header id="header" class="clearfix">
    <div class="container">
        <div class="col-group">
            <div class="site-name ">
                
                    <a id="logo" href="https://www.daleyblog.cn">
                        Mr.代的个人博客
                    </a>
                
                <p class="description">你所浪费的今天是昨天死去的人奢望的明天； 你所厌恶的现在是未来的你回不去的曾经</p>
            </div>
            <div>
                <nav id="nav-menu" class="clearfix">
                    <a class="current" href="https://www.daleyblog.cn">首页</a>
                    
                    <a  href="https://www.daleyblog.cn/archives/" title="归档">归档</a>
                    
                    <a  href="https://www.daleyblog.cn/about/" title="关于">关于</a>
                    
                </nav>
            </div>
        </div>
    </div>
</header>

    <div id="body">
        <div class="container">
            <div class="col-group">

                <div class="col-8" id="main">
                    
<div class="res-cons">
    <style type="text/css">
    .post-toc {
        position: fixed;
        width: 200px;
        margin-left: -210px;
        padding: 5px 10px;
        font-family: Athelas, STHeiti, Microsoft Yahei, serif;
        font-size: 12px;
        border: 1px solid rgba(0, 0, 0, .07);
        border-radius: 5px;
        background-color: rgba(255, 255, 255, 0.98);
        background-clip: padding-box;
        -webkit-box-shadow: 1px 1px 2px rgba(0, 0, 0, .125);
        box-shadow: 1px 1px 2px rgba(0, 0, 0, .125);
        word-wrap: break-word;
        white-space: nowrap;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
        z-index: 999;
        cursor: pointer;
        max-height: 70%;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .post-toc .post-toc-title {
        width: 100%;
        margin: 0 auto;
        font-size: 20px;
        font-weight: 400;
        text-transform: uppercase;
        text-align: center;
    }

    .post-toc .post-toc-content {
        font-size: 15px;
    }

    .post-toc .post-toc-content>nav>ul {
        margin: 10px 0;
    }

    .post-toc .post-toc-content ul {
        padding-left: 20px;
        list-style: square;
        margin: 0.5em;
        line-height: 1.8em;
    }

    .post-toc .post-toc-content ul ul {
        padding-left: 15px;
        display: none;
    }

    @media print,
    screen and (max-width:1057px) {
        .post-toc {
            display: none;
        }
    }
</style>
<div class="post-toc" style="position: absolute; top: 188px;">
    <h2 class="post-toc-title">文章目录</h2>
    <div class="post-toc-content">
        <nav id="TableOfContents">
  <ul>
    <li><a href="#1-添加用户-jupyter">1. 添加用户 jupyter</a></li>
    <li><a href="#2-下载并安装python3">2. 下载并安装python3</a></li>
    <li><a href="#3-修改环境变量并配置国内源">3. 修改环境变量并配置国内源</a></li>
    <li><a href="#4-安装jupyter-notebook">4. 安装jupyter-notebook</a></li>
    <li><a href="#5-配置并启动jupyter-notebook">5. 配置并启动jupyter-notebook</a></li>
  </ul>
</nav>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        var postToc = $(".post-toc");
        if (postToc.length) {
            var leftPos = $("#main").offset().left;
            if(leftPos<220){
                postToc.css({"width":leftPos-10,"margin-left":(0-leftPos)})
            }

            var t = postToc.offset().top - 20,
                a = {
                    start: {
                        position: "absolute",
                        top: t
                    },
                    process: {
                        position: "fixed",
                        top: 20
                    },
                };
            $(window).scroll(function () {
                var e = $(window).scrollTop();
                e < t ? postToc.css(a.start) : postToc.css(a.process)
            })
        }
    })
</script>
    <article class="post">
        <header>
            <h1 class="post-title">安装jupyter Notebook环境</h1>
        </header>
        <date class="post-meta meta-date">
            2020年12月9日
        </date>
        
        <div class="post-meta">
            <span>|</span>
            
            <span class="meta-category"><a href='/categories/Python'>Python</a></span>
            
            <span class="meta-category"><a href='/categories/AI'>AI</a></span>
            
        </div>
        
        
        <div class="post-meta">
            <span id="busuanzi_container_page_pv">|<span id="busuanzi_value_page_pv"></span><span>
                    阅读</span></span>
        </div>
        
        
        <div class="post-content">
            <h2 id="1-添加用户-jupyter">1. 添加用户 jupyter</h2>
<div class="highlight"><div style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell">adduser jupyter
passwd jupyter

su - jupyter
</code></pre></td></tr></table>
</div>
</div><h2 id="2-下载并安装python3">2. 下载并安装python3</h2>
<ol>
<li><a href="http://lib.csdn.net/base/python">Python</a>官网下载python3的源码包，网址：https://www.<a href="http://lib.csdn.net/base/python">python</a>.org/</li>
<li>百度云地址：链接:https://pan.baidu.com/s/1z9ZSWrclsNmMq-Hr2a5Nhg  密码:u19m</li>
</ol>
<div class="highlight"><div style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">5
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell">tar -xvzf Python-3.7.3.tgz        <span style="color:#8f5902;font-style:italic">#释放文件</span>
<span style="color:#204a87">cd</span> Python-3.7.3/                  <span style="color:#8f5902;font-style:italic">#进入目录</span>
./configure --prefix<span style="color:#ce5c00;font-weight:bold">=</span>/usr/python3 <span style="color:#8f5902;font-style:italic">#添加配置</span>
make                              <span style="color:#8f5902;font-style:italic">#编译源码</span>
make install                      <span style="color:#8f5902;font-style:italic">#执行安装</span>
</code></pre></td></tr></table>
</div>
</div><h2 id="3-修改环境变量并配置国内源">3. 修改环境变量并配置国内源</h2>
<div class="highlight"><div style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 8
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 9
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">10
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">11
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">12
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">13
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">14
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">15
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">16
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">17
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell"><span style="color:#8f5902;font-style:italic"># python环境变量配置</span>
vi ~/.bash_profile
<span style="color:#204a87">export</span> <span style="color:#000">PYTHON3</span><span style="color:#ce5c00;font-weight:bold">=</span>/home/jupyter/python3.7
<span style="color:#204a87">export</span> <span style="color:#000">PATH</span><span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#000">$PYTHON3</span>/bin:<span style="color:#000">$PATH</span>

<span style="color:#204a87">source</span> ~/.bash_profile

<span style="color:#8f5902;font-style:italic"># python配置国内源</span>
mkdir ~/.pip
vi ~/.pip/pip.conf
<span style="color:#8f5902;font-style:italic"># ---------------------------------文件编辑--------------------------------------------------------------------</span>
<span style="color:#ce5c00;font-weight:bold">[</span>global<span style="color:#ce5c00;font-weight:bold">]</span> 
index-url <span style="color:#ce5c00;font-weight:bold">=</span> https://pypi.tuna.tsinghua.edu.cn/simple
<span style="color:#ce5c00;font-weight:bold">[</span>install<span style="color:#ce5c00;font-weight:bold">]</span>
trusted-host <span style="color:#ce5c00;font-weight:bold">=</span> https://pypi.tuna.tsinghua.edu.cn  <span style="color:#8f5902;font-style:italic"># trusted-host 此参数是为了避免麻烦，否则使用的时候可能会提示不受信任</span>
<span style="color:#8f5902;font-style:italic"># ------------------------------------------------------------------------------------------------------------</span>
<span style="color:#8f5902;font-style:italic">#保存退出 </span>
</code></pre></td></tr></table>
</div>
</div><h2 id="4-安装jupyter-notebook">4. 安装jupyter-notebook</h2>
<pre><code>pip3 install jupyter 
</code></pre><h2 id="5-配置并启动jupyter-notebook">5. 配置并启动jupyter-notebook</h2>
<div class="highlight"><div style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4">
<table style="border-spacing:0;padding:0;margin:0;border:0;width:auto;overflow:auto;display:block;"><tr><td style="vertical-align:top;padding:0;margin:0;border:0;">
<pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 1
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 2
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 3
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 4
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 5
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 6
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 7
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 8
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"> 9
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">10
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">11
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">12
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">13
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">14
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">15
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">16
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">17
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">18
</span><span style="margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f">19
</span></code></pre></td>
<td style="vertical-align:top;padding:0;margin:0;border:0;;width:100%">
<pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-shell" data-lang="shell">jupyter notebook --generate-config
<span style="color:#8f5902;font-style:italic">#会生成一个配置文件，成功后会显示文件路径:（/home/jupyter/.jupyter/jupyter_notebook_config.py）</span>

<span style="color:#8f5902;font-style:italic">#修改配置</span>
vi /home/jupyter/.jupyter/jupyter_notebook_config.py
<span style="color:#8f5902;font-style:italic"># ---------------------------------文件编辑--------------------------------------------------------------------</span>
c.NotebookApp.ip<span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#4e9a06">&#39;*&#39;</span> <span style="color:#8f5902;font-style:italic"># *代表所有机器都可访问，或者输入服务ip</span>
c.NotebookApp.notebook_dir <span style="color:#ce5c00;font-weight:bold">=</span> u<span style="color:#4e9a06">&#39;/home/jupyter/jupyter_notebook&#39;</span> <span style="color:#8f5902;font-style:italic"># 创建的工作目录</span>
c.NotebookApp.open_browser <span style="color:#ce5c00;font-weight:bold">=</span> False   <span style="color:#8f5902;font-style:italic"># 启动不自动开启网站</span>
c.NotebookApp.port <span style="color:#ce5c00;font-weight:bold">=</span> <span style="color:#0000cf;font-weight:bold">8888</span>
<span style="color:#8f5902;font-style:italic"># ------------------------------------------------------------------------------------------------------------</span>
jupyter notebook password
<span style="color:#8f5902;font-style:italic">#输入2次密码，生成 jupyter_notebook_config.json 密码文件</span>
<span style="color:#8f5902;font-style:italic">#Enter password: </span>
<span style="color:#8f5902;font-style:italic">#Verify password: </span>
<span style="color:#8f5902;font-style:italic">#[NotebookPasswordApp] Wrote hashed password to /home/jupyter/.jupyter/jupyter_notebook_config.json</span>

<span style="color:#8f5902;font-style:italic">#启动jupyter-notebook</span>
nohup jupyter-notebook  --config<span style="color:#ce5c00;font-weight:bold">=</span>/root/.jupyter/jupyter_notebook_config.py <span style="color:#000;font-weight:bold">&amp;</span>
</code></pre></td></tr></table>
</div>
</div>
        </div>

        
<div class="post-archive">
    <ul class="post-copyright">
        <li><strong>原文作者：</strong><a rel="author" href="https://www.daleyblog.cn">靈靈</a></li>
        <li style="word-break:break-all"><strong>原文链接：</strong><a href="https://www.daleyblog.cn/post/%E5%AE%89%E8%A3%85jupyter-notebook%E7%8E%AF%E5%A2%83/">https://www.daleyblog.cn/post/%E5%AE%89%E8%A3%85jupyter-notebook%E7%8E%AF%E5%A2%83/</a></li>
        <li><strong>版权声明：</strong>本作品采用<a rel="license" href="https://creativecommons.org/licenses/by-nc-nd/4.0/">知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议</a>进行许可，非商业转载请注明出处（作者，原文链接），商业转载请联系作者获得授权。</li>
    </ul>
</div>
<br/>



        

<div class="post-archive">
    <h2>See Also</h2>
    <ul class="listing">
        
        <li><a href="/about/">关于我</a></li>
        
        <li><a href="/archives/">归档</a></li>
        
        <li><a href="/search/">搜索</a></li>
        
    </ul>
</div>


        <div class="post-meta meta-tags">
            
            <ul class="clearfix">
                
                <li><a href='/tags/python'>python</a></li>
                
                <li><a href='/tags/AI'>AI</a></li>
                
            </ul>
            
        </div>
    </article>
    
    

    
    
    <div class="post bg-white">
      <script src="https://utteranc.es/client.js"
            repo= "Daleys/blogcomment"
            issue-term="pathname"
            theme="github-light"
            crossorigin="anonymous"
            async>
      </script>
    </div>
    
</div>

                    <footer id="footer">
    <div>
        &copy; 2020 <a href="https://www.daleyblog.cn">Mr.代的个人博客 By 靈靈</a>
        
    </div>
    <br />
    <div>
        <div class="github-badge">
            <a href="https://gohugo.io/" target="_black" rel="nofollow"><span class="badge-subject">Powered by</span><span class="badge-value bg-blue">Hugo</span></a>
        </div>
        <div class="github-badge">
            <a href="https://www.flysnow.org/" target="_black"><span class="badge-subject">Design by</span><span class="badge-value bg-brightgreen">飞雪无情</span></a>
        </div>
        <div class="github-badge">
            <a href="https://github.com/flysnow-org/maupassant-hugo" target="_black"><span class="badge-subject">Theme</span><span class="badge-value bg-yellowgreen">Maupassant</span></a>
        </div>
    </div>
</footer>


    
    <script type="text/javascript">
        window.MathJax = {
            tex2jax: {
                inlineMath: [['$', '$']],
                processEscapes: true
                }
            };
    </script>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML' async></script>

<a id="rocket" href="#top"></a>
<script type="text/javascript" src='/js/totop.js?v=0.0.0' async=""></script>

<script type="application/javascript">
var doNotTrack = false;
if (!doNotTrack) {
	window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
	ga('create', 'GA ID', 'auto');
	
	ga('send', 'pageview');
}
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>



    <script type="text/javascript" src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" async></script>




    <script src='/js/douban.js'></script>

                </div>

                <div id="secondary">
    <section class="widget">
        <form id="search" action='https://www.daleyblog.cn/search/' method="get" accept-charset="utf-8" target="_blank" _lpchecked="1">
      
      <input type="text" name="q" maxlength="20" placeholder="Search">
      <input type="hidden" name="sitesearch" value="https://www.daleyblog.cn">
      <button type="submit" class="submit icon-search"></button>
</form>
    </section>
    
    <section class="widget">
        <h3 class="widget-title">最近文章</h3>
<ul class="widget-list">
    
    <li>
        <a href="https://www.daleyblog.cn/post/%E5%AE%89%E8%A3%85jupyter-notebook%E7%8E%AF%E5%A2%83/" title="安装jupyter Notebook环境">安装jupyter Notebook环境</a>
    </li>
    
</ul>
    </section>

    

    <section class="widget">
        <h3 class="widget-title"><a href='/categories/'>分类</a></h3>
<ul class="widget-list">
    
    <li><a href="https://www.daleyblog.cn/categories/AI/">AI (1)</a></li>
    
    <li><a href="https://www.daleyblog.cn/categories/Python/">Python (1)</a></li>
    
</ul>
    </section>

    <section class="widget">
        <h3 class="widget-title"><a href='/tags/'>标签</a></h3>
<div class="tagcloud">
    
    <a href="https://www.daleyblog.cn/tags/AI/">AI</a>
    
    <a href="https://www.daleyblog.cn/tags/python/">python</a>
    
</div>
    </section>

    

</div>

            </div>
        </div>
    </div>
</body>

</html>